{% extends "/fragments/base.html" %}
{% block title %}测试到预发环境构建{% endblock %}

{% block content %}
<script src="{{ url_for('static', filename='js/pre_batch_deploy.js') }}"></script>

<h1 class="center">测试到预发环境构建</h1>
<div class="container">
    <div id="deploy_form_content w-auto">
        <h3>任务号:{{task_number}} 预发环境可部署任务列表：</h3>
        <form id="deploy_form" action="/deploy/pre_batch_deploy" method="post">
            <input type="hidden" id="task_number" name="task_number" value="{{task_number}}">
            <input type="hidden" id="array_length" name="array_length" value="{{git_data|length}}">
            <div class="mb-1">
                {% for data in git_data %}
                <div class="form-row mb-1 ">
                    <div class="col-auto" style="width: 110px;">
                        {% if loop.index==1 %}
                        <label for="display_to_build_{{loop.index}}">是否需要部署</label>
                        {% endif %}
                        <input disabled title="是否需要发布" name="display_to_build_{{loop.index}}"
                               id="display_to_build_{{loop.index}}"
                               class="form-control {% if data['need_to_deploy']==True %}bg-primary text-white{% endif %}"
                               value="{% if data['need_to_deploy']==True %}需要部署{% else %}不需部署{% endif %}">
                    </div>
                    <div class="col">
                        {% if loop.index==1 %}
                        <label for="gittag_{{loop.index}}">预发build通过版本号</label>
                        {% endif %}
                        <input type="hidden" id="need_to_deploy_{{loop.index}}" name="need_to_deploy_{{loop.index}}"
                               value="{{data['need_to_deploy']}}">
                        <input class="form-control col-sm-20"
                               type='text' id='gittag_{{loop.index}}'
                               name='gittag_{{loop.index}}' title="预发build通过发布版本号"
                               value="{{data['release_version']}}" required/>
                    </div>
                    <div class="col-auto">
                        {% if loop.index==1 %}
                        <div class="mb-2 text-center">单独部署</div>
                        {% endif %}
                        <button
                                data-value="{{loop.index}}" type="button"
                                class="btn btn-primary single_deploy">单独部署
                        </button>
                    </div>
                    <div class="col-auto">
                        {% if loop.index==1 %}
                        <div class="mb-2 text-center">查看日志</div>
                        {% endif %}
                        <button data-value="{{loop.index}}" data-sysid="{{data['sys_id']}}"
                                data-device-index="0"
                                type="button"
                                class="btn btn-primary single_check_log">查看日志
                        </button>
                    </div>
                    <div class="col-auto" style="width: 130px">
                        {% if loop.index==1 %}
                        <div class="mb-2 text-center">部署状态</div>
                        {% endif %}
                        <div class="progress" style="height:38px;">
                            <div id="progress_bar_{{loop.index}}" class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%;font-size: 14px;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
                        </div>
                    </div>
                </div>
                {% endfor %}
            </div>
            <button type="button" id="batch_deploy_button" class="btn btn-success mt-1 center">批量执行预发环境发布</button>
        </form>
    </div>

</div>

{% endblock %}